package com.voiceqsologger.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * WebSocket 基础配置
 */
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    private final com.voiceqsologger.websocket.StreamRecognizeHandler streamRecognizeHandler;
    private final com.voiceqsologger.websocket.InterviewCoachHandler interviewCoachHandler;

    public WebSocketConfig(com.voiceqsologger.websocket.StreamRecognizeHandler streamRecognizeHandler,
                           com.voiceqsologger.websocket.InterviewCoachHandler interviewCoachHandler) {
        this.streamRecognizeHandler = streamRecognizeHandler;
        this.interviewCoachHandler = interviewCoachHandler;
    }

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(streamRecognizeHandler, "/ws/asr").setAllowedOrigins("*");
        registry.addHandler(interviewCoachHandler, "/ws/coach").setAllowedOrigins("*");
    }
}


